package ds_recommended.self_chuli

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions.lit

import java.util.Properties

object get_userid_and_password {
  def main(args: Array[String]): Unit = {
    val spark=SparkSession.builder()
      .master("local[*]")
      .appName("得到用户的id和密码用来登录")
      .getOrCreate()

    val connect=new Properties()
    connect.setProperty("user","root")
    connect.setProperty("password","123456")
    connect.setProperty("driver","com.mysql.jdbc.Driver")

    val result=spark.read
      .jdbc("jdbc:mysql://192.168.67.193:3307/dwd?useSSL=false","order_info",connect)
      .select("user_id").distinct()
      .withColumn("password",lit("123456"))

   result.write.mode("overwrite")
     .jdbc("jdbc:mysql://192.168.67.193:3307/dws?useSSL=false","login",connect)




    spark.close()
  }

}
